package com.scedu.springcloud.controller;

import com.scedu.springcloud.springcloud.entity.CommonResult;
import com.scedu.springcloud.springcloud.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
class EchoController {
    @Value("${server.port}")
    private String port;

    //模拟数据库数据
    public  static HashMap<Long, Payment> hashMap=new HashMap<>();
    static {
        hashMap.put(1L,new Payment(1L,"001001"));
        hashMap.put(2L,new Payment(2L,"002002"));
        hashMap.put(3L,new Payment(3L,"003003"));
    }

    @GetMapping(value = "/paymentSQL/{id}")
    public CommonResult paymentSQL(@PathVariable Long id) {
        Payment payment =hashMap.get(id);
        return new CommonResult(200,"from mysql data is "+port,payment);
    }
}